package com.iterator.manager;

import org.apache.shiro.web.session.mgt.DefaultWebSessionManager;

import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import java.io.Serializable;

public class CustomSessionManager extends DefaultWebSessionManager {
    @Override
    protected Serializable getSessionId(ServletRequest request, ServletResponse response) {
        HttpServletRequest req = (HttpServletRequest)request;
        //后台
        String sessionId = req.getHeader("X-cskaoyan-mall-Admin-Token");
        if(sessionId != null && ! "".equals(sessionId))
            return sessionId;
        //前台
        String wxSessionId = req.getHeader("X-Litemall-Token");
        if(wxSessionId != null && ! "".equals(wxSessionId))
            return wxSessionId;
        return super.getSessionId(request, response);
    }
}
